<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>商品管理</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
    <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
    <script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>

<div class="row">
    <div class="col-md-4"></div>
    <div class="col-md-4">
        <div class="row">
            <div >
                <img width="500px" height="400px" src="${cake.image}">
            </div>
            <div>
                <table>
                    <tr>
                        <h1>名字：${cake.cname}</h1>
                    </tr>
                    <tr>
                        <h1>单价：${cake.price}</h1>
                    </tr>
                    <tr>
                        <h1>祝福语：${cake.blessing}</h1>
                    </tr>

                    <tr>

                        <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal1">购买</button>
                    </tr>

                </table>
            </div>
        </div>
    </div>
    <!-- 模态框（Modal） -->
    <div class="modal fade" id="myModal1" tabindex="-1" role="dialog" aria-labelledby="myModalLabel1" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                        &times
                    </button>
                    <h4 class="modal-title" id="myModalLabel1">
                        购买商品
                    </h4>
                </div>

                <div class="modal-body">
                    <input type="hidden" id="cid" value="${cake.cid}" ><br>
                    <input type="hidden" id="shopId" value="${cake.shop.shopId}"><br>
                    地址:<input type="text"   id="siteId"><br>
                    时间:<input type="text"   id="times" value="${cake.shop.time}"><br>
                    单价:<input type="text"   id="price" value="${cake.price}"><br>
                    数量:<input type="text"   id="numbers" value="${cake.quantity}"><br>
                    描述:<input type="text"   id="represent" value="${cake.shop.describe}"><br>
                </div>
                <div class="modal-footer">
                    <button onclick="add()" type="button" class="btn btn-primary">
                        购买
                    </button>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal -->
    </div>

    <div class="col-md-4">

        <tr>
<%--            * @service  服务--%>
<%--            * @desc  描述--%>
<%--            * @time  创建时间String 时间戳--%>
<%--            * @logistics   物流--%>
            <h1>店铺：${cake.shop.sname}</h1>
            <h1>信誉:${cake.shop.reputation}</h1>
            <h1>服务:${cake.shop.service}</h1>
            <h1>描述:${cake.shop.describe}</h1>
            <h1>创建时间:${cake.shop.time}</h1>
            <h1>物流:${cake.shop.logistics}</h1>

        </tr>

    </div>


</div>



<script type="text/javascript">
    function add() {
        var cid = $("#cid").val()
        var shopId = $("#shopId").val()
        var siteId = $("#siteId").val()
        var times = $("#times").val()
        var price = $("#price").val()
        var numbers = $("#numbers").val()
        var represent = $("#represent").val()

        $.ajax({
            type:"post",
            url:"${bp}/orders/insert",
            data:{"cid":cid,"shopId":shopId,"siteId":siteId,"times":times,"price":price,"numbers":numbers,"represent":represent},
            success : function (msg) {
                if(msg == 1){
                    alert("添加成功")
                    window.location.reload()
                }else{
                    alert("添加失败")
                }
            }
        })
    }
</script>
</body>
</html>
